/************************************************************************
***  tvm.h
***  this is the file that contains the interface of TVM - Testify Virtual 
***  Machine
***
***	anyone or any organization can redistribute or modify this file for  
***    any purposes as long as you keep this statement and the copyright
***	statement.
***    
***  @author Tata @date 2008/12/31 Copyright(C) 2009 - Tata
************************************************************************/



#ifndef _TVM_H_
#define _TVM_H_

#include "tvm_typedef.h"
#include "tvm_error.h"

#ifdef __cplusplus
extern "C" 
{
#endif

/*definitions for TVM_Run's return value*/
#define TVM_RET_NORMAL		0
#define TVM_RET_PAUSED	 	1
#define TVM_RET_HALTED		2
#define TVM_RET_ERROR		3
#define TVM_RET_WAITING		4


void TVM_Init(
			  uint8* code,					/*code buffer for tata*/
			  size_type size,						/*size of the tata code*/
			  KeySender key_sender,	/*callback function to send the key*/
			  Logger logger					/*callback function to log the TVM activities*/
			  );

size_type TVM_Run(void);

/*control functions*/
void TVM_Suspend(void);
void TVM_Resume(void);
void TVM_Stop(void);
void TVM_Restart(void);
void TVM_StartRecording(
						KeyFetcher keyFetcher, /*callback function to retrieve the key*/
						size_type noKeyIndicator,	/*the indicator to hint that the return value isn't a key*/
						Outputor outputor,		/*callback function to output generated tata code*/
						size_type period				/*period represented in millisecond*/
						);
void TVM_StopRecording(void);

/*trigger an event. the event id should be between 0-31*/
void TVM_TriggerEvent(size_type eventID);

/*error handling utilities*/
size_type TVM_GetLastError(void);
void TVM_ClearError(void);

#ifdef __cplusplus
}
#endif

#endif/*_TVM_H_*/
